package com.hello.sky.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hello.sky.annotation.AutoFill;
import com.hello.sky.enmu.OperationType;
import com.hello.sky.model.dto.SetmealPageQueryDTO;
import com.hello.sky.model.entity.Setmeal;
import com.hello.sky.model.entity.SetmealDish;
import com.hello.sky.model.vo.SetmealOverViewVO;
import com.hello.sky.model.vo.SetmealVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 套餐 Mapper 接口
 * </p>
 *
 * @author D
 */
@Mapper
public interface SetmealMapper extends BaseMapper<Setmeal> {

    @AutoFill(OperationType.INSERT)
    void addSetMeal(Setmeal setmeal);

    List<SetmealVO> getPage(@Param("dto") SetmealPageQueryDTO dto);

    SetmealVO getSetmealByIdResVo(@Param("id") Long id);

    @AutoFill(OperationType.UPDATE)
    void updateSetmeal(Setmeal setmeal);

    @AutoFill(OperationType.UPDATE)
    void updateSetmealStatus(Setmeal setmeal);

    void delBatchByIds(@Param("ids") Long... ids);

    List<Setmeal> selectByIds(@Param("delIds") List<Long> delIds);

    List<SetmealVO> getSetmealByCategoryIdResVo(@Param("id") Integer id, @Param("status") Integer status);

    List<SetmealDish> getSetmealDishBySetmealId(@Param("setmealId") Long setmealId);

    void updateStatusByIds(@Param("status") Integer status, @Param("setmealIds") List<Long> setmealIds);

    @Select("select sum(status = 1) sold, sum(status = 0) discontinued from setmeal")
    SetmealOverViewVO overviewSetmeals();
}
